/**
 * 
 */
package com.lanswon.qzsmk.service.commonService.impl;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.lanswon.qzsmk.exception.ErrorCode;
import com.lanswon.qzsmk.model.Personal;
import com.lanswon.qzsmk.service.cardManageService.ApplyCardService;
import com.lanswon.qzsmk.service.cardManageService.LossAndUnbindService;
import com.lanswon.qzsmk.service.cardManageService.SupplementCardService;
import com.lanswon.qzsmk.service.commonService.DockingInternetService;
import com.lanswon.qzsmk.service.systemManageService.BranchManageService;
import com.lanswon.qzsmk.service.systemManageService.ParamManageService;
import com.lanswon.qzsmk.vo.LossCardInfo;
import com.lanswon.qzsmk.vo.ResultStatus;
import com.lanswon.qzsmk.vo.ResultVo;
import com.lanswon.qzsmk.vo.SupplementCardInfo;

/**
 * @author sun
 *
 */
@WebService
@Service
public class DockingInternetServiceImpl implements DockingInternetService {

	@Autowired
	LossAndUnbindService lossAndUnbindService;
	
	@Autowired
	SupplementCardService supplementCardService;
	
	@Autowired
	BranchManageService branchManageService;
	
	@Autowired
	ApplyCardService applyCardService;
	
	@Autowired
	ParamManageService paramManageService;

	@Override
	public ResultVo queryLossCard(LossCardInfo lci) {
		
		return lossAndUnbindService.queryLossCard(lci);
	}
	
	@Override
	public ResultVo queryPersonalByCertNo(String certNo) {
		
		return lossAndUnbindService.queryPersonal(certNo);
	}

	@Override
	@Transactional(rollbackFor=Exception.class,propagation = Propagation.REQUIRED)
	public ResultVo commitLossCardInfo(LossCardInfo lci) throws Exception {
		
		return lossAndUnbindService.commitLossCardInfo(lci);
	}

	@Override
	public ResultVo querySupplementCard(SupplementCardInfo sci) {
		
		return supplementCardService.querySupplementCard(sci);
	}

	@Override
	@Transactional(rollbackFor=Exception.class,propagation = Propagation.REQUIRED)
	public ResultVo commitSupplementCardInfo(SupplementCardInfo sci) {
		
		return supplementCardService.commitSupplementCardInfo(sci);
	}

	@Override
	public ResultVo queryBranchInternet(String streetId, String orgProperty,String serverType) {
		
		return branchManageService.queryBranchInternet(streetId, orgProperty,serverType);
	}
	
	

	@Override
	public ResultVo checkIsCardProductbyPaperNo(String paperType, String paperNo, String cardProductCode) {
		
		return applyCardService.checkIsCardProductbyPaperNo(paperType, paperNo, cardProductCode);
	}

	@Override
	@Transactional(rollbackFor=Exception.class,propagation = Propagation.REQUIRED)
	public ResultVo singleApplication(Personal p, String cardProductCode, String cardPhysicalType) {
		
		return applyCardService.singleApplication(p, cardProductCode, cardPhysicalType);
	}
	
	@Override
	
	public ResultVo queryPersonalByPaperNoAndPaperType(String paperType, String paperNo) {
		
		return applyCardService.queryPersonalByPaperNoAndPaperType(paperType, paperNo);
	}
	
	@Override
	public ResultVo queryApplySchedule(String paperNo, String paperType, String cardPCode) {
		
		return applyCardService.queryApplySchedule(paperNo, paperType, cardPCode);
	}
	
	@Override
	public ResultVo queryAllCertificates() {
		
		return paramManageService.queryAllCertificates();
	}

	@Override
	public ResultVo queryAllCardProdunctDefinition() {
		
		return paramManageService.queryAllCardProdunctDefinition_internet();
	}

	@Override
	public ResultVo queryAllCardPhysicsType() {
		
		return paramManageService.queryAllCardPhysicsType();
	}

	@Override
	public ResultVo queryPersonalCardInfoAndConsumeRecordsByPaperNo(String citizenCardNo, String year,String month,String tradeCondition,String appFlag) {
		
		return paramManageService.queryPersonalCardInfoAndConsumeRecordsByPaperNo(citizenCardNo,  year, month, tradeCondition, appFlag);
	}

	
	@Override
	public ResultVo queryCardProdunctByPersonal(String paperType, String paperNo, String cardPCode) {
		
		return paramManageService.queryCardProdunctByPersonal(paperType, paperNo, cardPCode);
	}

	@Override
	public ResultVo queryNation() {
		
		return paramManageService.queryNation();
	}

	@Override
	public ResultVo queryOrgByName(String branchName) {
		return branchManageService.queryOrgByName(branchName);
	}

	@Override
	public ResultVo queryOrgProperty() {
		return branchManageService.queryOrgProperty();
	}

	@Override
	public ResultVo queryAllBranchStreet() {
		
		ResultVo v = new ResultVo();
		try {
			v =  branchManageService.queryAllBranchStreet();
		} catch (Exception e) {
			e.printStackTrace();
			e.printStackTrace();
			ResultStatus s = new ResultStatus();
			s.setCode(ErrorCode.OTHER_EXCEPTION);
			s.setMessage("网点异常，无法获取，请联系管理员");
			v.setResultStatus(s);
		}
		return v;
	}

	
	@Override
	public String testWS() {
		// TODO Auto-generated method stub
		return "测试连接成功ws,fuck u !!!!";
	}
	
	
	
}
